home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $VER: LibInit.c 43.4 (3.1.97)
- **
- ** Library initializers and functions to be called by StartUp.c
- **
- ** (C) Copyright 1996-97 Andreas R. Kleinert
- ** All Rights Reserved.
- */
-
- #define __USE_SYSBASE
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/libraries.h>
- #include <exec/execbase.h>
- #include <exec/resident.h>
- #include <exec/initializers.h>
- #include <datatypes/pictureclass.h>
-
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/datatypes.h>
-
- #include <class/classbase.h>
- #include "libfuncs.h"
-
-
- ULONG __saveds __stdargs L_OpenLibs(void);
- void __saveds __stdargs L_CloseLibs(void);
-
- extern struct ClassBase *ClassBase;
-
-
- struct ExecBase *SysBase = NULL;
- struct DosLibrary *DOSBase = NULL;
- struct IntuitionBase *IntuitionBase = NULL;
- struct GfxBase *GfxBase = NULL;
- struct Library *UtilityBase = NULL;
- struct Library *DataTypesBase = NULL;
- struct Library *SuperClassBase = NULL;
- struct Library *IFFParseBase = NULL;
-
-
- #define VERSION 43
- #define REVISION 3
-
- char __aligned ExLibName [] = "samplePNM.datatype";
- char __aligned ExLibID [] = "samplePNM 43.3 (30.11.96)";
- char __aligned Copyright [] = "(C)opyright 1996 by Andreas R. Kleinert. All rights reserved.";
-
- extern ULONG InitTab[];
-
- extern APTR EndResident; /* below */
-
- struct Resident __aligned ROMTag =
- {
- RTC_MATCHWORD,
- &ROMTag,
- &EndResident,
- RTF_AUTOINIT,
- VERSION,
- NT_LIBRARY,
- 0,
- &ExLibName[0],
- &ExLibID[0],
- &InitTab[0]
- };
-
- APTR EndResident;
-
- struct MyDataInit
- {
- UWORD ainit1; UWORD binit1; UWORD ln_type;
- UBYTE ainit2; UBYTE binit2; ULONG ln_name2;
- UWORD ainit3; UWORD binit3; UWORD lib_flags;
- UWORD ainit4; UWORD binit4; UWORD lib_version;
- UWORD ainit5; UWORD binit5; UWORD lib_revision;
- UBYTE ainit6; UBYTE binit6; ULONG lib_idstring2;
- ULONG end;
- } DataTab =
- {
- INITBYTE(OFFSET(Node, ln_Type), NT_LIBRARY),
- 0x80, (UBYTE) OFFSET(Node, ln_Name), (ULONG) &ExLibName[0],
- INITBYTE(OFFSET(Library, lib_Flags), LIBF_SUMUSED|LIBF_CHANGED),
- INITWORD(OFFSET(Library, lib_Version), VERSION),
- INITWORD(OFFSET(Library, lib_Revision), REVISION),
- 0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &ExLibID[0],
- (ULONG) 0
- };
-
- /* Libraries not shareable between Processes or libraries messing
- with RamLib (deadlock and crash) may not be opened here - open/close
- these later locally and or maybe close them fromout L_CloseLibs()
- when expunging !
- */
-
- ULONG __saveds __stdargs L_OpenLibs(void)
- {
- SysBase = (*((struct ExecBase **) 4));
-
- DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 39);
- if(!DOSBase) return(FALSE);
-
- IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 39);
- if(!IntuitionBase) return(FALSE);
-
- GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 39);
- if(!GfxBase) return(FALSE);
-
- UtilityBase = (struct Library *) OpenLibrary("utility.library", 39);
- if(!UtilityBase) return(FALSE);
-
- DataTypesBase = (struct Library *) OpenLibrary("datatypes.library", 39);
- if(!DataTypesBase) return(FALSE);
-
- SuperClassBase = (struct Library *) OpenLibrary("datatypes/picture.datatype", 39);
- if(!SuperClassBase) return(FALSE);
-
- IFFParseBase = (struct Library *) OpenLibrary("iffparse.library", 37);
- if(!IFFParseBase) return(FALSE);
-
-
- ClassBase->cb_SysBase = (struct ExecBase *) SysBase;
-
- ClassBase->cb_DOSBase = (struct DosLibrary *) DOSBase;
- ClassBase->cb_IntuitionBase = (struct IntuitionBase *) IntuitionBase;
- ClassBase->cb_GfxBase = (struct GfxBase *) GfxBase;
- ClassBase->cb_UtilityBase = (struct Library *) UtilityBase;
- ClassBase->cb_DataTypesBase = (struct Library *) DataTypesBase;
- ClassBase->cb_SuperClassBase = (struct Library *) SuperClassBase;
- ClassBase->cb_IFFParseBase = (struct Library *) IFFParseBase;
-
- if(ClassBase->cb_Class = initClass(ClassBase)) return(TRUE);
-
- return(FALSE);
- }
-
- void __saveds __stdargs L_CloseLibs(void)
- {
- if(ClassBase->cb_Class) FreeClass(ClassBase->cb_Class);
-
- if(IFFParseBase) CloseLibrary((struct Library *) IFFParseBase);
- if(SuperClassBase) CloseLibrary((struct Library *) SuperClassBase);
- if(DataTypesBase) CloseLibrary((struct Library *) DataTypesBase);
- if(UtilityBase) CloseLibrary((struct Library *) UtilityBase);
- if(GfxBase) CloseLibrary((struct Library *) GfxBase);
- if(IntuitionBase) CloseLibrary((struct Library *) IntuitionBase);
- if(DOSBase) CloseLibrary((struct Library *) DOSBase);
- }
-